1
|
|
|
/* |
2
|
|
|
* To change this license header, choose License Headers in Project Properties. |
3
|
|
|
* To change this template file, choose Tools | Templates |
4
|
|
|
* and open the template in the editor. |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
var JobSeekerAPI = {}; |
9
|
|
|
JobSeekerAPI.jobSeekers = []; |
10
|
|
|
JobSeekerAPI.profilePicUploader = null; |
11
|
|
|
JobSeekerAPI.defaultFirstName = "Jane"; |
12
|
|
|
JobSeekerAPI.defaultLastName = "Doe"; |
13
|
|
|
|
14
|
|
|
JobSeekerAPI.JobSeekerProfileAnswer = function (question_id, answer) { |
15
|
|
|
this.job_seeker_profile_question_id = question_id; |
16
|
|
|
this.answer = answer; |
17
|
|
|
} |
|
|
|
|
18
|
|
|
|
19
|
|
|
JobSeekerAPI.JobSeeker = function ( |
20
|
|
|
id, |
21
|
|
|
name, |
22
|
|
|
email, |
23
|
|
|
personal_link, |
24
|
|
|
tagline, |
25
|
|
|
twitter_username, |
26
|
|
|
linkedin_username, |
27
|
|
|
answers, |
28
|
|
|
last_updated, |
29
|
|
|
user_id) { |
30
|
|
|
this.id = id; |
31
|
|
|
this.name = name; |
32
|
|
|
this.email = email; |
33
|
|
|
this.personal_link = personal_link; |
34
|
|
|
this.tagline = tagline; |
35
|
|
|
this.twitter_username = twitter_username; |
36
|
|
|
this.linkedin_username = linkedin_username; |
37
|
|
|
this.answers = answers; |
38
|
|
|
this.last_updated = last_updated; |
39
|
|
|
this.user_id = user_id; |
40
|
|
|
}; |
41
|
|
|
|
42
|
|
|
JobSeekerAPI.localizeJobSeekerProfile = function () { |
43
|
|
|
if (siteContent) { |
|
|
|
|
44
|
|
|
document.getElementById("profileEditAnswerCancel").value = siteContent.cancel; |
45
|
|
|
document.getElementById("profileEditAnswerSave").value = siteContent.save; |
46
|
|
|
} |
47
|
|
|
} |
|
|
|
|
48
|
|
|
|
49
|
|
|
JobSeekerAPI.populateJobSeekerObject = function (jobSeekerJSON) { |
50
|
|
|
var jobSeekerObj = new JobSeekerAPI.JobSeeker(); |
51
|
|
|
|
52
|
|
|
if (jobSeekerJSON) { |
53
|
|
|
jobSeekerObj.id = jobSeekerJSON.job_seeker_profile_id; |
54
|
|
|
jobSeekerObj.name = jobSeekerJSON.job_seeker_profile_name; |
55
|
|
|
jobSeekerObj.email = jobSeekerJSON.job_seeker_profile_email; |
56
|
|
|
jobSeekerObj.personal_link = jobSeekerJSON.job_seeker_profile_link; |
57
|
|
|
jobSeekerObj.tagline = jobSeekerJSON.job_seeker_profile_tagline; |
58
|
|
|
jobSeekerObj.twitter_username = jobSeekerJSON.job_seeker_profile_twitter_link; |
59
|
|
|
jobSeekerObj.linkedin_username = jobSeekerJSON.job_seeker_profile_linkedin_link; |
60
|
|
|
jobSeekerObj.last_updated = jobSeekerJSON.last_updated; |
61
|
|
|
jobSeekerObj.user_id = jobSeekerJSON.user_id; |
62
|
|
|
|
63
|
|
|
var answers = []; |
64
|
|
|
for (var i = 0; i < jobSeekerJSON.job_seeker_profile_answers.length; i++) { |
65
|
|
|
var jsonAnswer = jobSeekerJSON.job_seeker_profile_answers[i]; |
66
|
|
|
var answer = new JobSeekerAPI.JobSeekerProfileAnswer(jsonAnswer.job_seeker_profile_question_id, jsonAnswer.answer); |
67
|
|
|
answers.push(answer); |
68
|
|
|
} |
69
|
|
|
jobSeekerObj.answers = answers; |
70
|
|
|
} else { |
71
|
|
|
//TODO: make more robust |
72
|
|
|
//jobSeekerJSON could not be parsed, probably because profile doesnt exist yet |
73
|
|
|
// Show default values. |
74
|
|
|
jobSeekerObj.id = 0; |
75
|
|
|
jobSeekerObj.name = ""; |
76
|
|
|
jobSeekerObj.email = ""; |
77
|
|
|
jobSeekerObj.personal_link = ""; |
78
|
|
|
jobSeekerObj.tagline = ""; |
79
|
|
|
jobSeekerObj.twitter_username = ""; |
80
|
|
|
jobSeekerObj.linkedin_username = ""; |
81
|
|
|
jobSeekerObj.answers = []; |
82
|
|
|
jobSeekerObj.last_updated = ""; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
Utilities.debug ? console.log(jobSeekerObj) : null; |
|
|
|
|
86
|
|
|
|
87
|
|
|
return jobSeekerObj; |
88
|
|
|
}; |
89
|
|
|
|
90
|
|
|
JobSeekerAPI.refreshJobSeekerProfilePic = function () { |
91
|
|
|
if (UserAPI.hasSessionUser()) { |
|
|
|
|
92
|
|
|
var user_id = UserAPI.getSessionUserAsJSON()["user_id"]; |
|
|
|
|
93
|
|
|
//profile_pic_elements = [document.getElementById("myProfilePic"), document.getElementById("profileBasicInfoEditProfilePic")]; |
94
|
|
|
profile_pic_elements = [document.getElementById("myProfilePic")]; |
|
|
|
|
95
|
|
|
ProfilePicAPI.refreshMultipleProfilePicsBackground(user_id, profile_pic_elements); |
|
|
|
|
96
|
|
|
} |
97
|
|
|
}; |
98
|
|
|
|
99
|
|
|
JobSeekerAPI.populateJobSeekerProfile = function (jobSeekerProfile) { |
100
|
|
|
|
101
|
|
|
var profile_name = document.getElementById("updateProfileApplicantProfileFormNameLabelSpan"); |
102
|
|
|
profile_name.innerHTML = jobSeekerProfile.name; |
103
|
|
|
|
104
|
|
|
var profile_id = document.getElementById("profileId"); |
105
|
|
|
profile_id.value = jobSeekerProfile.id; |
106
|
|
|
|
107
|
|
|
var last_updated = document.getElementById("profileLastUpdated"); |
108
|
|
|
last_updated.value = jobSeekerProfile.last_updated; |
109
|
|
|
|
110
|
|
|
var profile_tagline = document.getElementById("updateProfileApplicantProfileFormTaglineLabelSpan"); |
111
|
|
|
profile_tagline.innerHTML = jobSeekerProfile.tagline; |
112
|
|
|
|
113
|
|
|
var twitter_name = document.getElementById("applicantProfileTwitterUsername"); |
114
|
|
|
var twitter_link = document.getElementById("profileTwitterLink"); |
115
|
|
|
var twitter_link_wrapper = document.getElementById("profileTwitterLinkWrapper"); |
116
|
|
|
if (jobSeekerProfile.twitter_username == null || jobSeekerProfile.twitter_username == "") { |
|
|
|
|
117
|
|
|
twitter_link_wrapper.classList.add("hidden"); |
118
|
|
|
twitter_link.href = "#"; |
119
|
|
|
twitter_name.value = ""; |
120
|
|
|
} else { |
121
|
|
|
twitter_link_wrapper.classList.remove("hidden"); |
122
|
|
|
twitter_link.href = JobSeekerAPI.twitterUsernameToLink(jobSeekerProfile.twitter_username); |
123
|
|
|
twitter_name.value = jobSeekerProfile.twitter_username; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
var linkedin_name = document.getElementById("profileLinkedInUsername"); |
127
|
|
|
var linkedin_link = document.getElementById("profileLinkedinLink"); |
128
|
|
|
var linkedin_link_wrapper = document.getElementById("profileLinkedinLinkWrapper"); |
129
|
|
|
if (jobSeekerProfile.linkedin_username == null || jobSeekerProfile.linkedin_username == "") { |
|
|
|
|
130
|
|
|
linkedin_link_wrapper.classList.add("hidden"); |
131
|
|
|
linkedin_link.href = ""; |
132
|
|
|
linkedin_name.value = ""; |
133
|
|
|
} else { |
134
|
|
|
linkedin_link_wrapper.classList.remove("hidden"); |
135
|
|
|
linkedin_link.href = unescape("https://www.linkedin.com/in/" + jobSeekerProfile.linkedin_username); |
136
|
|
|
linkedin_name.value = jobSeekerProfile.linkedin_username; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
//Populate answer fields |
140
|
|
|
var job_seeker_profile_answers = jobSeekerProfile.answers; |
141
|
|
|
for (var i = 0; i < job_seeker_profile_answers.length; i++) { |
142
|
|
|
if (job_seeker_profile_answers[i] !== undefined) { |
143
|
|
|
var questionId = job_seeker_profile_answers[i].job_seeker_profile_question_id; |
144
|
|
|
var selector = ".profile-question__answer[data-question-id=\"" + questionId + "\"]"; |
145
|
|
|
var answerField = document.querySelector(selector); |
146
|
|
|
if (answerField) { |
147
|
|
|
answerField.innerHTML = job_seeker_profile_answers[i].answer; |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
} |
151
|
|
|
}; |
152
|
|
|
|
153
|
|
|
JobSeekerAPI.resetProfileEditValues = function () { |
154
|
|
|
if (UserAPI.hasSessionUser()) { |
|
|
|
|
155
|
|
|
var sessionUser = UserAPI.getSessionUserAsJSON(); |
156
|
|
|
|
157
|
|
|
var profile_edit_name = document.getElementById("profileEditName"); |
158
|
|
|
profile_edit_name.value = sessionUser.name; |
159
|
|
|
} |
160
|
|
|
var profile_edit_tagline = document.getElementById("profileEditTagline"); |
161
|
|
|
profile_edit_tagline.value = document.getElementById("updateProfileApplicantProfileFormTaglineLabelSpan").innerHTML; |
162
|
|
|
|
163
|
|
|
var profile_edit_twitter = document.getElementById("profileEditTwitter"); |
164
|
|
|
profile_edit_twitter.value = document.getElementById("applicantProfileTwitterUsername").value; |
165
|
|
|
|
166
|
|
|
var profile_edit_linkedin = document.getElementById("profileEditLinkedin"); |
167
|
|
|
profile_edit_linkedin.value = document.getElementById("profileLinkedInUsername").value; |
168
|
|
|
}; |
169
|
|
|
|
170
|
|
|
JobSeekerAPI.twitterLinkToUsername = function (twitterLink) { |
171
|
|
|
if (twitterLink.startsWith("https://twitter.com/")) { |
172
|
|
|
return '@' + twitterLink.substring(20); |
173
|
|
|
} else { |
|
|
|
|
174
|
|
|
return twitterLink; |
175
|
|
|
} |
176
|
|
|
}; |
177
|
|
|
|
178
|
|
|
JobSeekerAPI.twitterUsernameToLink = function (twitterUsername) { |
179
|
|
|
if (twitterUsername.indexOf('@') == 0) { |
|
|
|
|
180
|
|
|
return "https://twitter.com/" + twitterUsername.substring(1); |
181
|
|
|
} else { |
|
|
|
|
182
|
|
|
return twitterUsername; |
183
|
|
|
} |
184
|
|
|
}; |
185
|
|
|
|
186
|
|
|
JobSeekerAPI.saveJobSeekerProfileChanges = function () { |
187
|
|
|
var jobSeekerBasicInfoForm = document.getElementById("profileBasicInfoForm"); |
188
|
|
|
|
189
|
|
|
var jobSeekerProfile = new JobSeekerAPI.JobSeeker(); |
190
|
|
|
var user = null; |
|
|
|
|
191
|
|
|
if (UserAPI.hasSessionUser()) { |
|
|
|
|
192
|
|
|
user = UserAPI.getSessionUserAsJSON(); |
193
|
|
|
} else { |
194
|
|
|
user = UserAPI.User(); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/*user.firstname = jobSeekerBasicInfoForm.elements.profileEditFirstName.value; |
198
|
|
|
user.lastname = jobSeekerBasicInfoForm.elements.profileEditLastName.value;*/ |
199
|
|
|
|
200
|
|
|
jobSeekerProfile.id = document.getElementById("profileId").value; |
201
|
|
|
|
202
|
|
|
jobSeekerProfile.last_updated = document.getElementById("profileLastUpdated").value; |
203
|
|
|
|
204
|
|
|
jobSeekerProfile.tagline = document.getElementById("profileEditTagline").value; |
205
|
|
|
|
206
|
|
|
jobSeekerProfile.twitter_username = jobSeekerBasicInfoForm.elements.profileEditTwitter.value; |
207
|
|
|
|
208
|
|
|
jobSeekerProfile.linkedin_username = escape(jobSeekerBasicInfoForm.elements.profileEditLinkedin.value); |
209
|
|
|
|
210
|
|
|
//Get answer values |
211
|
|
|
var answers = []; |
212
|
|
|
var answerFields = document.querySelectorAll(".profile-question__answer"); |
213
|
|
|
|
214
|
|
|
for (var i = 0; i < answerFields.length; i++) { |
215
|
|
|
var questionId = answerFields[i].getAttribute("data-question-id"); |
216
|
|
|
var answerText = answerFields[i].innerHTML; |
217
|
|
|
if (questionId) { |
218
|
|
|
answers.push(new JobSeekerAPI.JobSeekerProfileAnswer(questionId, answerText)); |
219
|
|
|
} |
220
|
|
|
} |
221
|
|
|
jobSeekerProfile.answers = answers; |
222
|
|
|
|
223
|
|
|
jobSeekerProfile.personal_link = ""; |
224
|
|
|
jobSeekerProfile.last_updated = ""; |
225
|
|
|
|
226
|
|
|
//function(firstName, lastName, tagline, twitter, linkedin) { |
227
|
|
|
if (FormValidationAPI.validateUpdateProfileBasicInfo( |
|
|
|
|
228
|
|
|
//user.firstname, user.lastname, |
229
|
|
|
jobSeekerProfile.twitter_username, jobSeekerProfile.linkedin_username)) { |
230
|
|
|
//Also trigger photo upload |
231
|
|
|
if (JobSeekerAPI.profilePicUploader) { |
232
|
|
|
JobSeekerAPI.profilePicUploader.uploadPhoto(); |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
//change twitter username to link |
236
|
|
|
//jobSeekerProfile.twitter_username = JobSeekerAPI.twitterUsernameToLink(jobSeekerProfile.twitter_username); |
237
|
|
|
|
238
|
|
|
JobSeekerAPI.saveJobSeekerProfile(jobSeekerProfile); |
239
|
|
|
} |
240
|
|
|
}; |
241
|
|
|
|
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* |
245
|
|
|
* @param {type} contactId |
246
|
|
|
* @returns {undefined} |
247
|
|
|
*/ |
248
|
|
|
JobSeekerAPI.saveJobSeekerProfile = function (jobSeekerProfile) { |
249
|
|
|
var user = UserAPI.getSessionUserAsJSON(); |
|
|
|
|
250
|
|
|
var saveJobSeekerProfile_url = DataAPI.baseURL + "/putJobSeekerProfileByUser/" + user.user_id; |
|
|
|
|
251
|
|
|
var jsonData = JSON.stringify(jobSeekerProfile); |
252
|
|
|
DataAPI.sendRequest(saveJobSeekerProfile_url, 'PUT', {}, jsonData, function(request){ |
253
|
|
|
JobSeekerAPI.hideJobSeekerProfileEditOverlays(); |
254
|
|
|
JobSeekerAPI.saveJobSeekerProfileLoaded(request.response); |
255
|
|
|
}); |
256
|
|
|
}; |
257
|
|
|
|
258
|
|
|
JobSeekerAPI.saveJobSeekerProfileLoaded = function (response) { |
259
|
|
|
Utilities.debug ? console.log(response) : null; |
|
|
|
|
260
|
|
|
DataAPI.getJobSeekerProfileByUserId(UserAPI.getSessionUserAsJSON().user_id, function (response) { |
|
|
|
|
261
|
|
|
var jobSeekerProfile = JobSeekerAPI.populateJobSeekerObject(JSON.parse(response)); |
262
|
|
|
JobSeekerAPI.resetProfileEditValues(); |
263
|
|
|
JobSeekerAPI.populateJobSeekerProfile(jobSeekerProfile); |
264
|
|
|
}); |
265
|
|
|
}; |
266
|
|
|
|
267
|
|
|
JobSeekerAPI.showMyJobSeekerProfile = function () { |
268
|
|
|
var stateInfo = {pageInfo: 'my_profile', pageTitle: 'Talent Cloud: My Profile'}; |
269
|
|
|
document.title = stateInfo.pageTitle; |
270
|
|
|
history.pushState(stateInfo, stateInfo.pageInfo, '#MyProfile');//last parameter just replaced with #MyProfile instead of url |
|
|
|
|
271
|
|
|
|
272
|
|
|
TalentCloudAPI.hideAllContent(); |
|
|
|
|
273
|
|
|
//TalentCloudAPI.hideLogo(); |
274
|
|
|
|
275
|
|
|
var jobSeekerProfileOverlay = document.getElementById("profileSection"); |
276
|
|
|
jobSeekerProfileOverlay.classList.remove("hidden"); |
277
|
|
|
|
278
|
|
|
var profileBasicInfoEdit = document.getElementById("profileBasicInfoEditWrapper"); |
279
|
|
|
profileBasicInfoEdit.classList.remove("hidden"); |
280
|
|
|
|
281
|
|
|
LookupAPI.getLookupResponse("job_seeker_profile_question", function (questionLookupMap) { |
|
|
|
|
282
|
|
|
JobSeekerAPI.addProfileQuestionSections(questionLookupMap, true); |
283
|
|
|
|
284
|
|
|
//Questions must be loaded before profile, with answers, can be populated |
285
|
|
|
DataAPI.getJobSeekerProfileByUserId(UserAPI.getSessionUserAsJSON().user_id, function (response) { |
|
|
|
|
286
|
|
|
var jobSeekerProfile = JobSeekerAPI.populateJobSeekerObject(JSON.parse(response)); |
287
|
|
|
JobSeekerAPI.populateJobSeekerProfile(jobSeekerProfile); |
288
|
|
|
}); |
289
|
|
|
}); |
290
|
|
|
|
291
|
|
|
EventsAPI.hideBodyOverflow(false); |
|
|
|
|
292
|
|
|
//AccessibilityAPI.preventModalEscapeBackward("jobSeekerCloseButton"); |
293
|
|
|
//AccessibilityAPI.preventModalEscapeForward("goToAccomplishmentsButton"); |
294
|
|
|
|
295
|
|
|
|
296
|
|
|
AccessibilityAPI.addEscapeListener("JobSeekerAPI.hideJobSeekerProfileEditOverlays", null); |
|
|
|
|
297
|
|
|
JobSeekerAPI.refreshJobSeekerProfilePic(); |
298
|
|
|
|
299
|
|
|
// New Subpage Hero Scripts |
300
|
|
|
|
301
|
|
|
Utilities.getHeroElements(); |
|
|
|
|
302
|
|
|
|
303
|
|
|
var profileHeroTitle = document.getElementById("profileHeroTitle"); |
304
|
|
|
profileHeroTitle.classList.remove("hidden"); |
305
|
|
|
profileHeroTitle.setAttribute("aria-hidden", "false"); |
306
|
|
|
|
307
|
|
|
// Mobile Menu Overflow Release |
308
|
|
|
document.body.style.overflowY = "auto"; |
309
|
|
|
|
310
|
|
|
// Google Analytics |
311
|
|
|
|
312
|
|
|
ga('set', 'page', '/my-profile'); |
313
|
|
|
ga('send', 'pageview'); |
314
|
|
|
}; |
315
|
|
|
|
316
|
|
|
JobSeekerAPI.showJobSeekerProfileForApplication = function (jobSeekerProfile, applicationId) { |
317
|
|
|
var stateInfo = {pageInfo: 'view_application_profile', pageTitle: 'Talent Cloud: Applicant Profile'}; |
318
|
|
|
document.title = stateInfo.pageTitle; |
319
|
|
|
history.pushState(stateInfo, stateInfo.pageInfo, '#ViewApplicationProfile/' + applicationId); |
|
|
|
|
320
|
|
|
|
321
|
|
|
TalentCloudAPI.hideAllContent(); |
|
|
|
|
322
|
|
|
//TalentCloudAPI.hideLogo(); |
323
|
|
|
|
324
|
|
|
var jobSeekerProfileOverlay = document.getElementById("profileSection"); |
325
|
|
|
jobSeekerProfileOverlay.classList.remove("hidden"); |
326
|
|
|
|
327
|
|
|
var profileBasicInfoEdit = document.getElementById("profileBasicInfoEditWrapper"); |
328
|
|
|
profileBasicInfoEdit.classList.add("hidden"); |
329
|
|
|
|
330
|
|
|
LookupAPI.getLookupResponse("job_seeker_profile_question", function (questionLookupMap) { |
|
|
|
|
331
|
|
|
JobSeekerAPI.addProfileQuestionSections(questionLookupMap, false); |
332
|
|
|
|
333
|
|
|
//Questions must be loaded before profile, with answers, can be populated |
334
|
|
|
JobSeekerAPI.populateJobSeekerProfile(jobSeekerProfile); |
335
|
|
|
}); |
336
|
|
|
|
337
|
|
|
EventsAPI.hideBodyOverflow(false); |
|
|
|
|
338
|
|
|
//AccessibilityAPI.preventModalEscapeBackward("jobSeekerCloseButton"); |
339
|
|
|
//AccessibilityAPI.preventModalEscapeForward("goToAccomplishmentsButton"); |
340
|
|
|
|
341
|
|
|
AccessibilityAPI.addEscapeListener("JobSeekerAPI.hideJobSeekerProfileEditOverlays", null); |
|
|
|
|
342
|
|
|
ProfilePicAPI.refreshProfilePicBackground(jobSeekerProfile.user_id, document.getElementById("myProfilePic")); |
|
|
|
|
343
|
|
|
|
344
|
|
|
// New Subpage Hero Scripts |
345
|
|
|
|
346
|
|
|
Utilities.getHeroElements(); |
|
|
|
|
347
|
|
|
|
348
|
|
|
var profileHeroTitle = document.getElementById("profileHeroTitle"); |
349
|
|
|
profileHeroTitle.classList.remove("hidden"); |
350
|
|
|
profileHeroTitle.setAttribute("aria-hidden", "false"); |
351
|
|
|
|
352
|
|
|
// Mobile Menu Overflow Release |
353
|
|
|
document.body.style.overflowY = "auto"; |
354
|
|
|
|
355
|
|
|
// Google Analytics |
356
|
|
|
|
357
|
|
|
//TODO: ensure GA calls are correct |
358
|
|
|
ga('set', 'page', '/profile-for-application/' + applicationId); |
359
|
|
|
ga('send', 'pageview'); |
360
|
|
|
}; |
361
|
|
|
|
362
|
|
|
/** |
363
|
|
|
* |
364
|
|
|
* @param {type} questionLookupMap - array of objects with .id, .description, .value properties |
365
|
|
|
* @return {undefined} |
366
|
|
|
*/ |
367
|
|
|
JobSeekerAPI.addProfileQuestionSections = function (questionLookupMap, isEditable) { |
368
|
|
|
//Create and populate Profile Question field elements |
369
|
|
|
var questionFragment = document.createDocumentFragment(); |
370
|
|
|
|
371
|
|
|
|
372
|
|
|
for (var i = 0; i < questionLookupMap.length; i++) { |
373
|
|
|
var question = questionLookupMap[i]; |
374
|
|
|
|
375
|
|
|
var questionSection = JobSeekerAPI.createQuestionSectionElement(question, isEditable); |
376
|
|
|
|
377
|
|
|
//Add to the wrapper fragment |
378
|
|
|
questionFragment.appendChild(questionSection); |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
var questionWrapper = document.getElementById("profileQuestionsWrapper"); |
382
|
|
|
//Clear previous values to avoid doubles |
383
|
|
|
questionWrapper.innerHTML = ""; |
384
|
|
|
|
385
|
|
|
//Add questions to wrapper |
386
|
|
|
questionWrapper.appendChild(questionFragment); |
387
|
|
|
}; |
388
|
|
|
|
389
|
|
|
|
390
|
|
|
JobSeekerAPI.createQuestionSectionElement = function (question, isEditable) { |
391
|
|
|
var questionSection = document.createElement("div"); |
392
|
|
|
questionSection.classList.add("applicant-profile__question"); |
393
|
|
|
|
394
|
|
|
var questionTitleBar = document.createElement("h4"); |
395
|
|
|
questionTitleBar.classList.add("applicant-profile__question-title-wrapper"); |
396
|
|
|
|
397
|
|
|
var questionTitle = document.createElement("span"); |
398
|
|
|
questionTitle.innerHTML = question.value; |
399
|
|
|
|
400
|
|
|
var questionAnswer = document.createElement("p"); |
401
|
|
|
questionAnswer.classList.add("profile-question__answer"); |
402
|
|
|
questionAnswer.setAttribute("data-question-id", question.id); |
403
|
|
|
|
404
|
|
|
//Now put it all together, from the inside out |
405
|
|
|
questionTitleBar.appendChild(questionTitle); |
406
|
|
|
|
407
|
|
|
questionSection.appendChild(questionTitleBar); |
408
|
|
|
questionSection.appendChild(questionAnswer); |
409
|
|
|
|
410
|
|
|
if (isEditable === true) { |
411
|
|
|
var questionEditBtn = document.createElement("a"); |
412
|
|
|
questionEditBtn.classList.add("applicant-profile__edit-trigger"); |
413
|
|
|
questionEditBtn.setAttribute("role", "button"); |
414
|
|
|
questionEditBtn.href = "javascript:void(0)"; |
|
|
|
|
415
|
|
|
questionEditBtn.setAttribute("title", 'Edit "' + question.value + '"'); |
416
|
|
|
|
417
|
|
|
var questionEditBtnScreenReaderText = document.createElement("span"); |
418
|
|
|
questionEditBtnScreenReaderText.classList.add("hidden"); |
419
|
|
|
questionEditBtnScreenReaderText.innerHTML = 'Edit "'+question.value+'"'; |
420
|
|
|
|
421
|
|
|
questionEditBtn.appendChild(questionEditBtnScreenReaderText); |
422
|
|
|
|
423
|
|
|
questionEditBtn.setAttribute("data-question-id", question.id); |
424
|
|
|
questionEditBtn.setAttribute("data-question-value", question.value); |
425
|
|
|
questionEditBtn.setAttribute("data-question-description", question.description); |
426
|
|
|
|
427
|
|
|
questionEditBtn.onclick = function () { |
428
|
|
|
var id = this.getAttribute("data-question-id"); |
429
|
|
|
var value = this.getAttribute("data-question-value"); |
430
|
|
|
var description = this.getAttribute("data-question-description"); |
431
|
|
|
JobSeekerAPI.showEditProfileAnswerModal(id, value, description); |
432
|
|
|
}; |
433
|
|
|
|
434
|
|
|
var questionEditBtnImage = document.createElement("i"); |
435
|
|
|
questionEditBtnImage.classList.add("fa"); |
436
|
|
|
questionEditBtnImage.classList.add("fa-pencil-square"); |
437
|
|
|
|
438
|
|
|
//Append edit button |
439
|
|
|
questionEditBtn.appendChild(questionEditBtnImage); |
440
|
|
|
questionTitleBar.appendChild(questionEditBtn); |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
return questionSection; |
444
|
|
|
}; |
445
|
|
|
|
446
|
|
|
JobSeekerAPI.showEditProfileAnswerModal = function (questionId, questionName, questionDescription) { |
447
|
|
|
if (siteContent) { |
|
|
|
|
448
|
|
|
var title = siteContent.editYour + " \"" + questionName + "\""; |
449
|
|
|
} else { |
450
|
|
|
var title = "Edit your \"" + questionName + "\""; |
|
|
|
|
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
|
454
|
|
|
document.getElementById("profileEditAnswerTitle").title = title; |
|
|
|
|
455
|
|
|
document.getElementById("profileEditAnswerTitle").innerHTML = title; |
|
|
|
|
456
|
|
|
document.getElementById("profileEditAnswerFormDescription").innerHTML = title; |
|
|
|
|
457
|
|
|
document.getElementById("profile-edit-answer__question-id").value = questionId; |
458
|
|
|
document.getElementById("profileEditAnswerLabel").innerHTML = questionName; |
459
|
|
|
document.getElementById("dialogueModalSupportCopy").innerHTML = questionDescription; |
460
|
|
|
|
461
|
|
|
var answerField = document.querySelector('.profile-question__answer[data-question-id="' + questionId + '"]'); |
462
|
|
|
if (answerField && answerField.innerHTML) { |
463
|
|
|
//If answer text already exists, prepopulate edit text box |
464
|
|
|
document.getElementById("profileEditAnswer").value = answerField.innerHTML; |
465
|
|
|
} else { |
466
|
|
|
//Else, reset text so placeholder shows |
467
|
|
|
document.getElementById("profileEditAnswer").value = ""; |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
//Unhide modal |
471
|
|
|
var jobSeekerAboutMeEditOverlay = document.getElementById("profileEditAnswerOverlay"); |
472
|
|
|
jobSeekerAboutMeEditOverlay.classList.remove("hidden"); |
473
|
|
|
|
474
|
|
|
AccessibilityAPI.preventModalEscape("profileEditAnswer", "profileEditAnswerSave"); |
|
|
|
|
475
|
|
|
AccessibilityAPI.focusElement("profileEditAnswer"); |
476
|
|
|
|
477
|
|
|
EventsAPI.hideBodyOverflow(true); |
|
|
|
|
478
|
|
|
|
479
|
|
|
modalSize(); |
480
|
|
|
}; |
481
|
|
|
|
482
|
|
|
JobSeekerAPI.saveJobSeekerProfileAnswer = function () { |
483
|
|
|
var questionId = document.getElementById("profile-edit-answer__question-id").value; |
484
|
|
|
if (questionId) { |
485
|
|
|
var answerField = document.querySelector('.profile-question__answer[data-question-id="' + questionId + '"]'); |
486
|
|
|
var answerText = document.getElementById("profileEditAnswer"); |
487
|
|
|
if (answerField && answerText) { |
488
|
|
|
Utilities.replaceElementText(answerField, answerText.value); |
|
|
|
|
489
|
|
|
JobSeekerAPI.saveJobSeekerProfileChanges(); |
490
|
|
|
} |
491
|
|
|
} |
492
|
|
|
JobSeekerAPI.hideJobSeekerProfileEditAnswerModal(); |
493
|
|
|
} |
|
|
|
|
494
|
|
|
|
495
|
|
|
JobSeekerAPI.hideJobSeekerProfileForm = function () { |
496
|
|
|
var jobSeekerProfileOverlay = document.getElementById("profileSection"); |
497
|
|
|
jobSeekerProfileOverlay.classList.add("hidden"); |
498
|
|
|
|
499
|
|
|
//EventsAPI.hideBodyOverflow(false); |
500
|
|
|
|
501
|
|
|
//FormsAPI.steppedForm.validateStep('contact_details','jobSeekerFormStepGroup',false,null,null); |
502
|
|
|
}; |
503
|
|
|
|
504
|
|
|
JobSeekerAPI.showJobSeekerProfileBasicInfoEdit = function () { |
505
|
|
|
//TODO: push state info to history |
506
|
|
|
|
507
|
|
|
var jobSeekerBasicInfoEditOverlay = document.getElementById("profileBasicInfoEditOverlay"); |
508
|
|
|
jobSeekerBasicInfoEditOverlay.classList.remove("hidden"); |
509
|
|
|
|
510
|
|
|
AccessibilityAPI.preventModalEscape("updateProfileChoosePhotoButtonLabel", "profileBasicInfoEditSave"); |
|
|
|
|
511
|
|
|
AccessibilityAPI.focusElement("updateProfileChoosePhotoButtonLabel"); |
512
|
|
|
|
513
|
|
|
EventsAPI.hideBodyOverflow(true); |
|
|
|
|
514
|
|
|
|
515
|
|
|
var fileInputButtons = [document.getElementById('updateProfileChoosePhotoButton'), |
516
|
|
|
document.getElementById('updateProfileChooseAltPhotoButton')]; |
517
|
|
|
var fileDrop = document.getElementById('updateProfilePhotoDraggableArea'); |
518
|
|
|
var imagePreview = document.getElementById('updateProfilePhotoCroppieContainer'); |
519
|
|
|
var clearBtn = document.getElementById('updateProfilePhotoCancelButton'); |
520
|
|
|
//var uploadBtn = document.getElementById('profilePicUploadBtn'); |
521
|
|
|
|
522
|
|
|
//Don't pass in a save button, because there is no dedicated button for pic uploading. |
523
|
|
|
//The save button must upload photo, as well as profile info. |
524
|
|
|
JobSeekerAPI.profilePicUploader = new ProfilePicAPI.Uploader( |
|
|
|
|
525
|
|
|
fileInputButtons, |
526
|
|
|
fileDrop, |
527
|
|
|
imagePreview, |
528
|
|
|
clearBtn, |
529
|
|
|
null, |
530
|
|
|
UserAPI.getSessionUserAsJSON().user_id, |
|
|
|
|
531
|
|
|
JobSeekerAPI.onProfilePicUploaded |
532
|
|
|
); |
533
|
|
|
|
534
|
|
|
modalSize(); |
535
|
|
|
|
536
|
|
|
}; |
537
|
|
|
|
538
|
|
|
JobSeekerAPI.hideJobSeekerProfileBasicInfoEdit = function () { |
539
|
|
|
//TODO modify state info history ? |
540
|
|
|
var jobSeekerBasicInfoEditOverlay = document.getElementById("profileBasicInfoEditOverlay"); |
541
|
|
|
jobSeekerBasicInfoEditOverlay.classList.add("hidden"); |
542
|
|
|
|
543
|
|
|
JobSeekerAPI.resetProfileEditValues(); |
544
|
|
|
|
545
|
|
|
EventsAPI.hideBodyOverflow(false); |
|
|
|
|
546
|
|
|
}; |
547
|
|
|
|
548
|
|
|
JobSeekerAPI.hideJobSeekerProfileEditAnswerModal = function () { |
549
|
|
|
var jobSeekerEditAnswerOverlay = document.getElementById("profileEditAnswerOverlay"); |
550
|
|
|
jobSeekerEditAnswerOverlay.classList.add("hidden"); |
551
|
|
|
|
552
|
|
|
JobSeekerAPI.resetProfileEditValues(); |
553
|
|
|
|
554
|
|
|
EventsAPI.hideBodyOverflow(false); |
|
|
|
|
555
|
|
|
}; |
556
|
|
|
|
557
|
|
|
JobSeekerAPI.hideJobSeekerProfileEditOverlays = function () { |
558
|
|
|
var jobSeekerBasicInfoEditOverlay = document.getElementById("profileBasicInfoEditOverlay"); |
559
|
|
|
jobSeekerBasicInfoEditOverlay.classList.add("hidden"); |
560
|
|
|
|
561
|
|
|
var jobSeekerEditAnswerOverlay = document.getElementById("profileEditAnswerOverlay"); |
562
|
|
|
jobSeekerEditAnswerOverlay.classList.add("hidden"); |
563
|
|
|
|
564
|
|
|
JobSeekerAPI.resetProfileEditValues(); |
565
|
|
|
|
566
|
|
|
EventsAPI.hideBodyOverflow(false); |
|
|
|
|
567
|
|
|
} |
|
|
|
|
568
|
|
|
|
569
|
|
|
JobSeekerAPI.showUploadProfilePic = function () { |
570
|
|
|
//TODO: enable slide transition between divs |
571
|
|
|
|
572
|
|
|
var profileBasicInfoFormWrapper = document.getElementById("profileBasicInfoFormWrapper"); |
573
|
|
|
profileBasicInfoFormWrapper.classList.add("hidden"); |
574
|
|
|
|
575
|
|
|
var profilePicUploadWrapper = document.getElementById("profilePicUploadWrapper") |
|
|
|
|
576
|
|
|
profilePicUploadWrapper.classList.remove("hidden"); |
577
|
|
|
|
578
|
|
|
// AccessibilityAPI.preventModalEscape("profilePicUploadField", "profilePicUploadBtn"); |
579
|
|
|
// AccessibilityAPI.focusElement("profilePicUploadField"); |
580
|
|
|
|
581
|
|
|
var fileInputButtons = [document.getElementById('updateProfileChoosePhotoButton'), |
582
|
|
|
document.getElementById('updateProfileChooseAltPhotoButton')]; |
583
|
|
|
var fileDrop = document.getElementById('updateProfilePhotoDraggableArea'); |
584
|
|
|
var imagePreview = document.getElementById('updateProfilePhotoCroppieContainer'); |
585
|
|
|
var clearBtn = document.getElementById('updateProfilePhotoCancelButton'); |
586
|
|
|
//var uploadBtn = document.getElementById('profilePicUploadBtn'); |
587
|
|
|
|
588
|
|
|
JobSeekerAPI.profilePicUploader = new ProfilePicAPI.Uploader( |
|
|
|
|
589
|
|
|
fileInputButtons, |
590
|
|
|
fileDrop, |
591
|
|
|
imagePreview, |
592
|
|
|
clearBtn, |
593
|
|
|
null, |
594
|
|
|
UserAPI.getSessionUserAsJSON().user_id, |
|
|
|
|
595
|
|
|
JobSeekerAPI.onProfilePicUploaded |
596
|
|
|
); |
597
|
|
|
|
598
|
|
|
}; |
599
|
|
|
|
600
|
|
|
JobSeekerAPI.onProfilePicUploaded = function () { |
601
|
|
|
JobSeekerAPI.refreshJobSeekerProfilePic(); |
602
|
|
|
}; |
603
|
|
|
|
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.
Further Readings: